#include <binomial.cc>
#include <cassert>
#include <iostream>

using namespace std;

bool ok = true;

void check_binomial(int a, int b, binomial_type expected) {
  binomial_type result = binomial(a, b);
  if (result != expected) {
    cout << "binomial(" << a << ", " << b << ") = " << result;
    cout << " instead of " << expected << endl;
  }
}

int main() {
  bin_init();
  for (int ii = 0; ii < MAX_BIN; ++ii) {
    check_binomial(ii, 0, 1);
    check_binomial(ii, ii, 1);
    if (ii > 0) {
      check_binomial(0, ii, 0);
      check_binomial(ii, 1, ii);
      check_binomial(ii, ii - 1, ii);
    }
  }
  check_binomial(4, 0, 1);
  check_binomial(4, 1, 4);
  check_binomial(4, 2, 6);
  check_binomial(4, 3, 4);
  check_binomial(4, 4, 1);
  check_binomial(4, 5, 0);
  check_binomial(5, 0, 1);
  check_binomial(5, 1, 5);
  check_binomial(5, 2, 10);
  check_binomial(5, 3, 10);
  check_binomial(5, 4, 5);
  check_binomial(5, 5, 1);
  check_binomial(5, 6, 0);
#ifdef BINOMIAL_LONG_LONG
  check_binomial(38, 19, 35345263800);
#endif
  if (ok) {
    return 0;
  } else {
    return 1;
  }
}
